#ifndef __CONSOLE_DEBUG_H__
#define __CONSOLE_DEBUG_H__

#ifdef __cplusplus
extern "C"
{
#endif


#include <stdlib.h>
#include <string.h>

#include <LowLevelIOInterface.h>
#include "bsp_uart.h"

#define DEBUG_COM   COM_RS232_Debug
#define DEBUG_COM_init(baud)  BSP_Uart3_Config(baud)


//#define DEBUG_PRINTF_ENABLE

#ifdef DEBUG_PRINTF_ENABLE

/*
线程安全的printf,需要互斥锁
*/
#define PRINTF_ERR(fmt,...)    do { xSemaphoreTake(DebugUART.Sema_PrintfMutex, 0xffff);\
                                        printf("[Err]%s(%d): " fmt"\r",/* __FILE__,*/__func__,__LINE__,##__VA_ARGS__);\
                                        xSemaphoreGive(DebugUART.Sema_PrintfMutex);\
                                      } while(0)

#define PRINTF_INFO(fmt,...)   do {  xSemaphoreTake(DebugUART.Sema_PrintfMutex, 0xffff);\
                                        printf("[OK]%s(%d): " fmt"\r",__func__, __LINE__, ##__VA_ARGS__);\
                                        xSemaphoreGive(DebugUART.Sema_PrintfMutex);\
                                      } while (0)

#else

#define PRINTF_ERR(fmt,...)     do{;}while(0)
#define PRINTF_INFO(fmt,...)    do{;}while(0)

#endif


										
										

#ifdef __cplusplus
}
#endif


#endif

